<?php
require_once 'Zend/Session/Namespace.php';

class IndexController extends Zend_Controller_Action
{
	function preDispatch()
	{
		$this->view->user = Zend_Auth::getInstance()->getIdentity();
		if($this->view->user =='')
		{
			$this->_redirect('/auth/login');
		}
	
		$this->view->user = Zend_Auth::getInstance()->getIdentity();
		$this->view->controller = $this->_request->getControllerName();
		$this->view->action = $this->_request->getActionName();
		$subMenu = array (
			'Main' => array (
				'key' => 'index',
				'url' => '/user/',
				'selected' => false,
				'title' => 'Page to list user todo, msg ...',
			),
			'My Tasks' => array (
				'key' => 'tasks',
				'url' => '/user/tasks',
				'selected' => false,
				'title' => 'Tasks assigned to me'
			),
			'Profile' => array (
				'key' => 'profile',
				'url' => '/user/profile',
				'selected' => false,
				'title' => 'Basic info, change password'
			),
			'Messages' => array (
				'key' => 'messages',
				'url' => '/user/messages',
				'selected' => false,
				'title' => 'Messages received by me'
			)
		);
		$menu = new Menu();
		$menuTree = $menu->renderMenu($this->_request->getControllerName(), $this->_request->getActionName(), $subMenu);
		/*echo $this->_request->getControllerName()." -> ".$this->_request->getActionName();
		exit;*/
		$this->view->menuTree = $menuTree;
		$this->view->metaTitle = "User - Task Tracking System V1.0";
	}
	
	public function indexAction()
	{	
		
	}	
	
	public function noRouteAction() 
    { 
        $this->_redirect('/'); 
    } 
}